/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package meg.ejb.entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.PrePersist;
import javax.persistence.SequenceGenerator;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 *
 * @author radek
 */
@Entity
public class Player implements Serializable {
    @Id
    @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="player_sequence")
    @SequenceGenerator(name="player_sequence", allocationSize=1)
    private int id;

    @NotNull
    @Size(min=5, max=15)
    @Column(length=15, unique=true)
    private String login;

    @NotNull
    @Size(min=1)
    @Column(length=512)
    private String password;

    @NotNull
    @Temporal(TemporalType.TIMESTAMP)
    private Date registeredDate;

    @PrePersist
    private void setDate() {
        if(registeredDate == null) {
            registeredDate = new Date();
        }
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getLogin() {
        return login;
    }

    public void setLogin(String login) {
        this.login = login;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public Date getRegisteredDate() {
        return registeredDate;
    }

    public void setRegisteredDate(Date registeredDate) {
        this.registeredDate = registeredDate;
    }
}
